package com.cloud.cmt.usermanage.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.cloud.cmt.usermanage.base.BaseEntity;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;

import javax.persistence.*;
import java.util.List;

/**
 * User: wcy
 * Date: 2017/10/17
 * Time: 15:42
 */
@Data
@Entity
public class Organization extends BaseEntity<Long>{

	@JsonProperty("uplink")
	@JSONField(name = "uplink")
	@ApiModelProperty(name = "uplink", notes = "父节点，没有父节点默认-1",example = "1")
	private Long uplink;
	@JsonProperty("org_name")
	@JSONField(name = "org_name")
	@ApiModelProperty(name = "org_name", notes = "机构名称", example = "主管")
	@NotBlank(message ="机构名称不能为空",groups=Organization.SAVE.class)
	private String orgName;
	@JsonProperty("remark")
	@JSONField(name = "remark")
	@ApiModelProperty(name = "remark", notes = "备注", example = "下面有一群小兵")
	private String remark;
	@ApiModelProperty(name = "org_address", notes = "机构地址", example = "杭州西湖边")
	@JSONField(name = "org_address")
	@JsonProperty("org_address")
	private String orgAddress;
	@ApiModelProperty(name = "rank", notes = "排序", example = "1")
	private Double rank;
	@JsonProperty("tenant_id")
	@JSONField(name = "tenant_id")
	@ApiModelProperty(name = "tenant_id", notes = "租户", example = "1")
	private String tenantId;

	@JsonProperty("manager")
	@JSONField(name = "manager")
	@ApiModelProperty(name = "manager", notes = "部门负责人id", example = "1")
	private Long manager;

	@Transient
	@ApiModelProperty(name = "children", notes = "组织子节点信息")
	private List<Organization> children;

	public interface SAVE{};
}
